package com.xiaoxiong.text;

/**
 * 加载中。。。Dialog
 * 可自己设置显示的信息
 * 默认为加载中。。。
 * 
 * @author xiaoxiong
 */

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;


public class LoadingDialog extends AlertDialog {

	private TextView tips_loading_msg;
	private TextView text2;
	private ProgressBar progressBar;
	private String message = null;

	public LoadingDialog(Context context) {
		super(context);
		message = getContext().getResources().getString(R.string.msg_login_ing);
	}

	public LoadingDialog(Context context, String message) {
		super(context);
		this.message = message;
	}

	public LoadingDialog(Context context, int theme, String message) {
		super(context, theme);
		this.message = message;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.view_tips_loading);
		tips_loading_msg = (TextView) findViewById(R.id.tips_loading_msg);
		text2 = (TextView) findViewById(R.id.text2);
		progressBar = (ProgressBar) findViewById(R.id.loading);
		tips_loading_msg.setText(this.message);
	}

	public void setText(String message) {
		this.message = message;
		tips_loading_msg.setText(this.message);
	}

	public void setText2(String message) {
		text2.setText(message);
	}
	
	public void setMax(int max){
		progressBar.setMax(max);
	}
	
	public void setProgress(int progress){
		progressBar.setProgress(progress);
	}

	public void setText(int resId) {
		setText(getContext().getResources().getString(resId));
	}

	// 设置弹出对话框能否取消
	public void setCancel(boolean is) {
		this.setCanceledOnTouchOutside(is);
	}

}
